<?php

namespace app\home\controller\record;

use app\home\controller\AuthController;
use app\home\model\store\StoreProduct;
use app\home\model\order\StoreOrder;
use services\{JsonService, UtilService as Util};
use app\home\model\user\User;
use app\home\model\user\UserBill;
use app\home\model\user\UserExtract;
use app\home\model\store\StoreCouponUser;

/**
 * 交易数据控制器
 * Class Record
 * @package app\home\controller\record
 */
class Record extends AuthController
{
    /**
     *显示操作记录
     */
    public function index()
    {

    }

    /**
     * 订单统计
     * @return string
     */
    public function chart_order()
    {
        $this->assign([
            'is_layui' => true,
            'year' => getMonth()
        ]);
        return $this->fetch();
    }

    /**
     * @return false|string
     */
    public function get_echarts_order()
    {
        $where = Util::getMore([
            ['type', ''],
            ['status', ''],
            ['data', ''],
        ]);
        return JsonService::successful(StoreOrder::getEchartsOrder($where));
    }

    /**
     * 显示产品记录
     */
    public function chart_product()
    {
        $this->assign([
            'is_layui' => true,
            'year' => getMonth()
        ]);
        return $this->fetch();
    }

    /**
     * 显示积分统计
     */
    public function chart_score()
    {
        $this->assign([
            'is_layui' => true,
            'year' => getMonth()
        ]);
        return $this->fetch();
    }

    /**
     * 显示优惠券统计
     */
    public function chart_coupon()
    {
        $this->assign([
            'is_layui' => true,
            'year' => getMonth()
        ]);
        return $this->fetch();
    }

    /**
     * 显示用户统计
     */
    public function user_chart()
    {
        $this->assign([
            'is_layui' => true,
            'year' => getMonth()
        ]);
        return $this->fetch();
    }

    /**
     * 会员业务
     */
    public function user_business_chart()
    {
        $limit = 10;
        $top10list = User::getUserTop10List($limit);
        $this->assign([
            'is_layui' => true,
            'limit' => $limit,
            'year' => getMonth(),
            'integralList' => $top10list['integral'],
            'moneyList' => $top10list['now_money'],
            'shopcountList' => $top10list['shopcount'],
            'orderList' => $top10list['order'],
            'lastorderList' => $top10list['lastorder']
        ]);
        return $this->fetch();
    }

    /**
     * 显示用户属性统计
     */
    public function user_attr()
    {
        $this->assign([
            'is_layui' => true,
            'year' => getMonth()
        ]);
        return $this->fetch();
    }
}